package com.yuandian.management.controller;

import com.yuandian.bpm.common.core.util.R;
import com.yuandian.management.service.ConfProbeConfigService;
import com.yuandian.management.vo.ProbeConfigVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * -Controller
 * @author zfsn
 * @date 2023-5-11
 */
@Api(tags = "探针管理-探针配置详情")
@RestController
@RequestMapping("/probeConfig")
public class ProbeConfigController {

	@Autowired
	private ConfProbeConfigService probeConfigService;

	/**
	 *  通过ip获取ip 配置详情
	 * @param ip
	 * @return
	 */
	@GetMapping("/getConfigDetailByIp/{ip}")
	@ApiOperation(value = "配置详情信息: 通过ip获取ip配置详情", notes = "配置详情信息: 通过ip获取ip配置详情")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "ip", value = "ip", paramType = "path", required = true, dataType = "String"),
	})
	public R getConfigDetailByIp(@PathVariable("ip") String ip) {
		return probeConfigService.getConfigDetailByIp(ip);
	}


	/**
	 * 更新探针 配置信息
	 * @param
	 * @return
	 */
	@PostMapping("/updateProbeConfigDetails")
	@ApiOperation(value = "配置详情信息-更新探针 配置信息", notes = "配置详情信息-更新探针 配置信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "configContext", value = "更新内容 json格式: [\\n\" +\n" +
					"\t\t\t\t\"    {\\n\" +\n" +
					"\t\t\t\t\"      \\\"configName\\\": \\\"open_http_decoder\\\",\\n\" +\n" +
					"\t\t\t\t\"      \\\"configDetails\\\": 1,\\n\" +\n" +
					"\t\t\t\t\"      \\\"valueType\\\": \\\"boolean\\\",\\n\" +\n" +
					"\t\t\t\t\"      \\\"remark\\\": \\\"http 协议解码器开关[0,1]\\\"\\n\" +\n" +
					"\t\t\t\t\"    }]", paramType = "body", required = true, dataType = "JSON"),
			@ApiImplicitParam(name = "ip", value = "ip", paramType = "body", required = true, dataType = "String"),
	})
	public R updateProbeConfigDetails(@RequestBody @ApiIgnore ProbeConfigVo probeConfigVo) {
		return probeConfigService.updateProbeConfigDetails(probeConfigVo);
	}




}
